const db = wx.cloud.database()

Page({
  data:{
    uid:"",
    goodLists:[],
    id:[]
  },
onLoad(){
   wx.showLoading({
     title:'加载中',
     mask:true
   })
   var uid = wx.getStorageSync('openid')
    console.log(uid)
      wx.cloud.callFunction({
        name:"getOrders",
        data:{
          uid:uid
        }
      }).then(res=>{
          console.log(res.result.data)
          // var id = []
          var goodLists = []
          for(var i=0;i<res.result.data.length;i++){
            var goods = res.result.data[i].goods
            var id = res.result.data[i]._id
            var total = res.result.data[i].total
            var num =  res.result.data[i].num
            var totalGoods = {goods,id,total,num}
            goodLists.unshift(totalGoods)
          //  goodLists.push(res.result.data[i].goods)
          //  id.push(res.result.data[i]._id)
         }
         console.log(goodLists)
        //  console.log(id)
          this.setData({
            // id:id,
            goodLists:goodLists
          })

          
      })
    setTimeout(function () {
      wx.hideLoading()
    }, 1000)
  }

})